package com.qianfeng.smartdevices.pojo;


import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import org.springframework.util.ObjectUtils;

import java.util.Objects;
@ApiModel(description = "区域对象数据")
public class Areas implements CheckNull{
  @ApiModelProperty(value = "父区域ID",example = "1")
  private Long parentid;
  @ApiModelProperty(value = "状态，0，禁用,1 启用",required = true,example = "1")
  private Long status;
  @ApiModelProperty(value = "区域名",required = true,example = "海淀区")
  private String areaname;
  private Long id;
@ApiModelProperty(value = "父区域名,查询时候返回",example = "海淀区",hidden = true)
  private String parentname;

  @Override
  public boolean isNull(CheckStatus status) {
    switch (status) {

      case ADD:
        return ObjectUtils.isEmpty(areaname);
      case UPDATE:
        return (id == null || id <= 0)||(ObjectUtils.isEmpty(parentid)&&ObjectUtils.isEmpty(this.status)&&ObjectUtils.isEmpty(areaname));
    }
    return false;
  }

  @Override
  public boolean equals(Object o) {
    if (this == o) return true;
    if (o == null || getClass() != o.getClass()) return false;
    Areas areas = (Areas) o;
    return Objects.equals(parentid, areas.parentid) && Objects.equals(status, areas.status) && Objects.equals(areaname, areas.areaname) && Objects.equals(id, areas.id) && Objects.equals(parentname, areas.parentname);
  }

  @Override
  public int hashCode() {
    return Objects.hash(parentid, status, areaname, id, parentname);
  }

  public String getParentname() {
    return parentname;
  }

  public void setParentname(String parentname) {
    this.parentname = parentname;
  }


  public Long getParentid() {
    return parentid;
  }

  public void setParentid(Long parentid) {
    this.parentid = parentid;
  }


  public Long getStatus() {
    return status;
  }

  public void setStatus(Long status) {
    this.status = status;
  }


  public String getAreaname() {
    return areaname;
  }

  public void setAreaname(String areaname) {
    this.areaname = areaname;
  }


  public Long getId() {
    return id;
  }

  public void setId(Long id) {
    this.id = id;
  }

}
